#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
启动API服务器
"""

import uvicorn
import os
import sys

# 添加项目路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from fastapi import FastAPI
from agent_mcp.app.routes1 import router

# 创建FastAPI应用
app = FastAPI(
    title="Agent MCP API",
    description="智能异常分析和处理API",
    version="1.0.0"
)

# 注册路由
app.include_router(router)

@app.get("/")
async def root():
    """根路径"""
    return {
        "message": "Agent MCP API 服务正在运行",
        "version": "1.0.0",
        "endpoints": {
            "llm_analysis": "/api/intelligent/process_llm_analysis"
        }
    }

@app.get("/health")
async def health_check():
    """健康检查"""
    return {"status": "healthy", "service": "agent_mcp_api"}

if __name__ == "__main__":
    print("=== 启动Agent MCP API服务器 ===")
    print("服务器地址: http://localhost:8000")
    print("API文档: http://localhost:8000/docs")
    print("健康检查: http://localhost:8000/health")
    print("LLM分析端点: http://localhost:8000/api/intelligent/process_llm_analysis")
    print("\n按 Ctrl+C 停止服务器")
    
    # 启动服务器
    uvicorn.run(
        "start_api_server:APP",
        host="0.0.0.0",
        port=8000,
        reload=True,
        log_level="info"
    ) 